;(function () {
	new Vue({
		el: '#jwk-order-detail',
		data () {
			return {
				power: JSON.parse(localStorage.getItem('permissions')),
				isSuccesDialog: false,
				isErrorDialog: false,
				urlParams: hlUrlUtil.$query(),
				successText: '',
				errorText: '',
				detailData: {}
			}
		},
		filters: {
			formatDate: function (time) {
			  if (time === undefined) return '--'
			  return hlDateUtil.formatUTCDate(time, 'yyyy-MM-dd')
			},
		},
		methods: {
			detailApi () {
				hlhttp.get({
					url: 'jwk/office_appointment',
					data: {appointment_id: this.urlParams.id},
					success: (res) => {
						this.detailData = res
					}
				})
			},
			//成交框框
			isShowKuanKuan (id) {
				this.isSuccesDialog = !this.isSuccesDialog;				
				if (!this.isSuccesDialog) {
					this.successText = ''
				}
			},
			//关闭框框
			isErrorKK (id) {
				this.isErrorDialog = !this.isErrorDialog;				
				if (!this.isErrorDialog) {
					this.errorText = ''
				}
			},
			//提交成功
			submitSuccess () {
				hlhttp.put({
					url: 'jwk/office_appointment/_deal',
					data: {
						appointment_id: this.urlParams.id,
						memo: this.successText
					},
					success: () => {
						hl.toast('操作成功')
						this.isShowKuanKuan()
						this.detailApi()
					}
				})
			},
			//提交关闭
			submitError () {
				if (!this.errorText) {
					hl.toast('失败原因必填')
					return
				}
				hlhttp.put({
					url: 'jwk/office_appointment/_close',
					data: {
						appointment_id: this.urlParams.id,
						memo: this.errorText
					},
					success: () => {
						hl.toast('操作成功')
						this.isErrorKK()
						this.detailApi()
					}
				})
			},
		},
		mounted () {
			this.detailApi()
		}
	})
} ())